package com.algo.common;

import org.apache.commons.lang3.StringUtils;

public interface ICodeMSG {

    int getCode();

    String getMessage();

    default String fullMessage() {
        return this.getCode() + " -> " + this.getMessage();
    }

    static ICodeMSG create(int code, String msg) {
        return new ICodeMSG() {
            @Override
            public int getCode() {
                return code;
            }

            @Override
            public String getMessage() {
                return StringUtils.defaultString(msg);
            }
        };
    }
}
